import dayjs from "dayjs"; // 文档 https://day.js.org/docs/en/display/format
// import { ElLoading, ElMessage } from 'element-plus';
// import './storage';

const utils = {
  dayjs: (val) => {
    // dayjs('2019-01-25').format('DD/MM/YYYY')
    return dayjs(val);
  },
  diffTime: (d1, d2, count) => {
    if (!d1 || !d2) {
      return {};
    }

    const date1 = utils.dayjs(d1);
    const date2 = utils.dayjs(d2);

    return {
      result: date1.diff(date2, "day") > count,
      resultText: date1.diff(date2, "day") > count ? "是" : "否",
      num: date1.diff(date2, "day"),
    };
  },
  getNewObj: (obj) => {
    return JSON.parse(JSON.stringify(obj));
  },
  sleep(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
  },
};
export default utils;
